home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / eflibpt4.zip / DEMO / DATATYPE / STACK2.PAS < prev    next >
Pascal/Delphi Source File  |  1996-08-18  |  1KB  |  40 lines

  1. { Borland Pascal Extended Function Library - EFLIB (C) Johan Larsson, 1996
  2.   Demonstration; dynamic stacks #2
  3.  
  4.   EFLIB IS PROTECTED BY THE COPYRIGHT LAW AND MAY NOT BE COPIED, SOLD OR
  5.   MANIPULATED. FOR MORE INFORMATION, SEE PROGRAM MANUAL! THIS DEMONSTRAT-
  6.   ION PROGRAM MAY FREELY BE USED AND DISTRIBUTED.                          }
  7.  
  8.  
  9. uses EFLIBDEF, EFLIBINI, EFLIBDAT, EFLIBOBJ, EFLIBSCR, EFLIBTXT;
  10.  
  11. const NumberOfElements = 1000;
  12.  
  13. var Index, Number : integer;
  14.     MyStack       : StackObjectType;
  15.  
  16. begin
  17.      WriteLn ('* Stack demonstration *');
  18.  
  19.      { Initialize dynamic stack and push integer numbers to stack }
  20.      with MyStack do begin
  21.           { Initialize a dynamic stack }
  22.           InitializeStack (SizeOf(Integer), FALSE);
  23.                           { Element size }  { Unrestricted access (overflow checking) }
  24.  
  25.           { Push (add) some numbers ... }
  26.           for Index := NumberOfElements downto 1 do Push (Index);
  27.  
  28.           { Pop (retrieve) numbers ... }
  29.           while not IsEmpty do begin
  30.                 Pop (Number);
  31.                 Write (Number:5);
  32.           end;
  33.  
  34.           WriteLn;
  35.  
  36.           Intercept;
  37.      end;
  38.      if GlobalDataError then WriteLn ('Error(s) reported!');
  39. end.
  40.